<?php
/**
 * Created by PhpStorm.
 * User: chenzhitao
 * Date: 2018/5/22
 * Time: 下午5:49
 */

namespace app\index\model;


use think\Model;

class SupCategory extends Model
{
    protected $table = 't_supqualify_category';
    public static function getCategoryNameById($id){
        $cateogory = self::find($id);
        return $cateogory['category_name'];

    }
    public static function getAll(){
        $data = self::where('flag', '=', 1)
            ->order('show_order desc')
            ->select();
        if($data->isEmpty()){
            return[];
        }
        $supcategory = [];
        foreach ($data as $item){
            $category_item['id'] = $item['id'];
            $category_item['category_name'] = $item['category_name'];
            array_push($supcategory,$category_item);
        }
        return $supcategory;
    }
    public static function getCategoryById($id){
        $data = self::find($id);
        return $data;
    }
}